package com.lqk.demo.pessimisticlock.reentrantLock;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author lqk
 * @date 2021/12/23 15:11
 */
@Slf4j
public class ReentrantLock5 {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        // 创建一个新的条件变量（休息室）
        Condition condition1 = lock.newCondition();
        Condition condition2 = lock.newCondition();
        lock.lock();
        try{
            // 进入休息室等待
            condition1.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }

        condition1.signal();    // 相当于notify
        condition1.signalAll(); // 相当于notifyAll
    }
}
